var ID=getQueryVariable("yp")
console.log(ID)
window.onload=function () {
    $.ajax({
        type:"get",
        url:"/category/getCategoryById",
        data:{
            id:ID
        },
        success:function (data) {
            $("#typee").val(data.name);
        }
    })
}

function Change() {
    var faq = document.getElementById("typee").value;
    var date={
        "id":ID,
        "name":faq
    };
    $.ajax({
        type:"POST",
        url:"/category/updateCategory",
        dataType:"json",
        contentType: 'application/json',
        data:JSON.stringify(date),
        success:function () {
            alert("修改成功！")
            window.location.href="type.html"
        }
    })
}

function getQueryVariable(variable)
{
    var query = window.location.search.substring(1);
    var vars = query.split("&");
    for (var i=0;i<vars.length;i++) {
        var pair = vars[i].split("=");
        if(pair[0] == variable){return pair[1];}
    }
    return(false);
}